package com.cloud_notes.demo.controller;

import com.cloud_notes.demo.common.pojo.request.UserLoginRequest;
import com.cloud_notes.demo.common.pojo.response.UserLoginResponse;
import com.cloud_notes.demo.service.UserLoginService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RequestMapping("/user")
@RestController
public class UserLoginController {
//    @Autowired
    @Resource(name = "userLoginServiceImpl")
    private UserLoginService userLoginService;

    //登录接口
    @RequestMapping("/login")
    public UserLoginResponse login(@Validated @RequestBody UserLoginRequest userLoginRequest){//@Validated注解对实体类进行校验，在类对象中直接添加注解
        log.info("用户登录：userName: {}",userLoginRequest.getUserName());
        //根据用户查询啊护具库，看是否存在
        return userLoginService.login(userLoginRequest);
    }
}
